package com.blb.socket;

import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Scanner;

/**
 * 处理写任务的线程
 */
public class WriteTask implements Runnable {

    private DataOutputStream out;

    public WriteTask(DataOutputStream out) {
        this.out = out;
    }


    @Override
    public void run() {
        Scanner scanner = new Scanner(System.in);
        try {
            //不断发送数据
            for(;;){
                System.out.println("请输入要说的话：");
                String next = scanner.nextLine();
                out.writeUTF(next);
                out.flush();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
